// src/store/userSlice.js
import { createSlice } from "@reduxjs/toolkit";
import { title } from "@uiw/react-md-editor";

const userSlice = createSlice({
  name: "user",
  initialState: {
    role: "USER", // 用户角色
    userName: "匿名用户", // 用户名
    hasLuckyFrame: false, // 用户名
  },
  reducers: {
    setRole: (state, action) => {
      state.role = action.payload;
    },
    setUserName: (state, action) => {
      state.userName = action.payload;
    },
    logout: (state) => {
      state.role = "USER";
      state.userName = "";
    },
    setHasLuckyFrame: (state, action) => {
      state.hasLuckyFrame = action.payload;
    },
  },
});

export const { setRole, setUserName, logout, setHasLuckyFrame } = userSlice.actions;
export default userSlice.reducer;
